package com.futures.questionbank.adapter;

import android.os.Bundle;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.List;

public class TabFragmentPagerAdapter extends FragmentPagerAdapter {
    private FragmentManager mfragmentManager;
    private List<Fragment> mlist;


    public TabFragmentPagerAdapter(FragmentManager fm, List<Fragment> list) {
        super(fm);
        this.mlist = list;
        this.mfragmentManager = fm;
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
    }

    @Override
    public Fragment getItem(int arg0) {
        Fragment fragment = null;
        fragment = mlist.get(arg0);
        Bundle bundle = new Bundle();
        bundle.putString("id",""+arg0);
        fragment.setArguments(bundle);
       // return fragment;
        return mlist.get(arg0);
    }

    @Override
    public int getCount() {
        return mlist.size();//有几个页面
    }



    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
//                super.destroyItem(container, position, object);
      //  Fragment fragment = mlist.get(position);
     //   mfragmentManager.beginTransaction().hide(fragment).commit();
    }
}

